//
//  PerssonalProfileEditCell.m
//  ChatForHot
//
//  Created by wr on 2018/10/15.
//  Copyright © 2018年 FLY. All rights reserved.
//

#import "PerssonalProfileEditCell.h"
#import "PersonalCellModel.h"

@interface PerssonalProfileEditCell ()

@property (nonatomic, strong) UIImageView *HOTCHATmarkIcon;
@property (nonatomic, strong) UITextField *HOTCHATinputTextField;
@property (nonatomic, strong) UIView *HOTCHATlineview;
@property (nonatomic, assign) NSInteger HOTCHATcellTag;
@end

@implementation PerssonalProfileEditCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style
                    reuseIdentifier:reuseIdentifier]) {
        [self HOTCHATinitSubViews];
    }
    return self;
}

- (void)HOTCHATinitSubViews {
    self.HOTCHATmarkIcon = [[UIImageView alloc] init];
    [self.contentView addSubview:self.HOTCHATmarkIcon];
    
    self.HOTCHATinputTextField = [[UITextField alloc] init];
    self.HOTCHATinputTextField.font = [UIFont systemFontOfSize:15];
    self.HOTCHATinputTextField.textColor = [UIColor colorFromHexString:@"#AAAAAA"];
    [self.contentView addSubview:self.HOTCHATinputTextField];
    
    @weakify(self)
    [self.HOTCHATinputTextField.rac_textSignal subscribeNext:^(NSString *text) {
       @strongify(self)
        if (self.delegate && [self.delegate respondsToSelector:@selector(HOTCHATsetText:tag:)]) {
            @strongify(self);
            [self.delegate HOTCHATsetText:text tag:self.HOTCHATcellTag];
        }
    }];
    
    self.HOTCHATlineview = [[UIView alloc] init];
    self.HOTCHATlineview.backgroundColor = HOTCHATrgb(230, 230, 230);;
    [self.contentView addSubview:self.HOTCHATlineview];
}

- (void)HOTCHATbind:(PersonalCellModel *)model {
    _model = model;
    
    self.HOTCHATinputTextField.placeholder = model.title;
    self.HOTCHATinputTextField.text = model.info;
    
    [self.HOTCHATmarkIcon setImage:[UIImage imageNamed:model.icon]];
    
    self.HOTCHATcellTag = model.tag;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.HOTCHATmarkIcon.size = CGSizeMake(23, 23);
    self.HOTCHATmarkIcon.centerY = self.contentView.centerY;
    self.HOTCHATmarkIcon.left = 15;
    
    self.HOTCHATinputTextField.size = CGSizeMake(kScreenWidth - 60, 44);
    self.HOTCHATinputTextField.centerY = self.contentView.centerY;
    self.HOTCHATinputTextField.left = self.HOTCHATmarkIcon.right + 7;;
    
    self.HOTCHATlineview.size = CGSizeMake(kScreenWidth - 15, PixelOne);
    self.HOTCHATlineview.left = 15;
    self.HOTCHATlineview.bottom = self.contentView.bottom - PixelOne;
}
@end
